 $(function(){
    var length,
    currentIndex = 0,
    interval,
    hasStarted = false,//轮播图是否开始
    t = 5000;//轮播时间
    length = $('.scroll-li').length;
    $('.scroll-li:not(:first)').hide();
    $('.spot-ul li:first').addClass('on');
    $('.spot-ul li').hover(function(e){
        stop();
        var preIndex = $(".spot-ul li").filter(".on").index();
        currentIndex = $(this).index();
        play(preIndex, currentIndex);
    },
    function(){
        start();
    });
    function play(preIndex, currentIndex) {
        $('.scroll-li').eq(preIndex).fadeOut(500).parent().children().eq(currentIndex).fadeIn(500);
        $('.spot-ul li').removeClass('on');
        $('.spot-ul li').eq(currentIndex).addClass('on');
    }
    function next() {
        var preIndex = currentIndex;
        currentIndex = ++currentIndex % length;
        play(preIndex, currentIndex);
    }
    function start() {
        if(!hasStarted) {
        hasStarted = true;
        interval = setInterval(next, t);
        }
    }
    function stop() {
        clearInterval(interval);
        hasStarted = false;
    }
    start();
})